﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace ConsoleLib.Menu.TextualMenu
{
    public abstract class TextMenu
    {
        private string Title = "";
        private Dictionary<int,string> MenuItems = new Dictionary<int, string>();
        private int NumberOfItems = 0;

        abstract public bool createMenu();

        public bool  setTitle(string Title)
        {
            this.Title = Title;
            return true;
        }

        public string getTitle()
        {
            return this.Title;
        }

        public bool addItem(string name)
        {
            MenuItems.Add(this.NumberOfItems, name);
            this.NumberOfItems++;
            return true;
        }

        public bool drawMenu()
        {
            Console.WriteLine(this.Title);
            Console.WriteLine("\n");
            for (int i = 0; i < this.NumberOfItems; i++)
            {
                string toWrite = null;
                bool canWrite = MenuItems.TryGetValue(i,out toWrite);
                if (canWrite)
                {
                    Console.WriteLine(toWrite + "\n");
                }
                else return false;
            }
            return true;            
        }

        public int getNumberOfItems()
        {
            return this.NumberOfItems;
        }
    }
}
